﻿using System.Windows;
using System.Windows.Media;
using Box2DX.Collision;

namespace Expression.Samples.Physics {
	public interface IShapeProvider {
		FrameworkElement BodyShape { get; }
	}

	public interface IShapeGeometry {
		ShapeDef GetShapeDefinition(SimulatorContext context);
	}

	public interface IBodyMover {
		double ElementAngle { get; set; }
		Point ElementPosition { get; set; }
	}

	public class BodyMover: IBodyMover {

		private FrameworkElement element;

		private TranslateTransform translation = new TranslateTransform();
		private RotateTransform rotation = new RotateTransform();

		public BodyMover(FrameworkElement element) {
			this.element = element;

			TransformGroup transform = new TransformGroup();
			transform.Children.Add(this.rotation);
			transform.Children.Add(this.translation);

			this.element.RenderTransformOrigin = new Point(.5, .5);
			this.element.RenderTransform = transform;
		}

		public double ElementAngle {
			get {
				return this.rotation.Angle;
			}
			set {
				this.rotation.Angle = value;
			}
		}

		public Point ElementPosition {
			get {
				return new Point(this.translation.X, this.translation.Y);
			}
			set {
				this.translation.X = value.X;
				this.translation.Y = value.Y;
			}
		}
	}
}
